package com.neusoft.elmboot.service.impl;

import java.math.BigDecimal;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.neusoft.elmboot.mapper.FoodMapper;
import com.neusoft.elmboot.po.Food;
import com.neusoft.elmboot.service.FoodService;
import org.springframework.transaction.annotation.Transactional;

@Service
public class FoodServiceImpl implements FoodService{
	
	@Autowired
	private FoodMapper foodMapper;

	@Override
	public List<Food> listFoodByBusinessId(Integer businessId) {
		return foodMapper.listFoodByBusinessId(businessId);
	}
	
	@Override
	public int removeFood(Integer foodId) {
		return foodMapper.removeFood(foodId);
	}

	@Override
	public int addFood(Food food) {
		return foodMapper.addFood(food);
	}
	
	@Override
	@Transactional
	public int updateFoodPrice(Food food) {
		if (food.getFoodId() == null || food.getFoodPrice() == null || food.getFoodPrice() <= 0) {
			throw new IllegalArgumentException("无效的商品ID或价格");
		}
		return foodMapper.updateFoodPrice(food);
	}

}
